Implementing a Callback Service

If your integration uses a Callback service you can implement it as shown in the example below.

Example: /jumio-callback Endpoint

package com.acme.demowithsdk;

import com.jumio.sdk.callback.model.CallbackRequestBody;
import com.jumio.sdk.kyx.JumioClient;
import com.jumio.sdk.retrieval_v3.model.WorkflowExecutionResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping("/jumio-callback")
public class JumioCallbackRestController {

    private final JumioClient jumioClient;

    private static final Logger logger = LoggerFactory.getLogger(JumioCallbackRestController.class);

    public JumioCallbackRestController(JumioClient jumioClient) {
        this.jumioClient = jumioClient;
    }

    @PostMapping
    public void handleCallback(@RequestBody CallbackRequestBody callbackRequestBody) {
        final UUID workflowExecutionId = callbackRequestBody.getWorkflowExecution().getId();

        final String workflowExecutionStatus = callbackRequestBody.getWorkflowExecution().getStatus();
        if (!"PROCESSED".equalsIgnoreCase(workflowExecutionStatus)) {
            logger.warn("Workflow {} has not been processed. Status is {}", workflowExecutionId, workflowExecutionStatus);
            return;
        }

        final WorkflowExecutionResponse workflowExecutionResponse = jumioClient.retrieveData(callbackRequestBody);
        if (!"PASSED".equalsIgnoreCase(workflowExecutionResponse.getDecision().getType())) {
            logger.warn("ID Scan has been rejected for {}", workflowExecutionId);
            return;
        }

        logger.info("Verification {} successfully processed.", workflowExecutionId);
    }
}